import request from './index'

const service = request

// 登录接口
export function login(data) {
    return service({
        url: '/user/login',
        method: 'post',
        data
    })
}

// 注册接口
export function register(data) {
    return service({
        url: '/user/register',
        method: 'post',
        data
    })
}

// 修改密码
export function updatePassword(data) {
    return request({
        url: '/user/password',
        method: 'post',
        data
    })
}


// 获取用户列表
export const getUserList = (page, size, params) => {
    return request({
        url: '/user?page=' + page + '&size=' + size,
        method: 'get',
        params
    })
}

// 添加用户
export const addUser = (data) => {
    return request({
        url: '/user',
        method: 'post',
        data
    })
}
// 修改用户信息
export const updateUser = (id, data) => {
    return request({
        url: '/user/' + id,
        method: 'put',
        data
    })
}

// 删除用户
export const deleteUser = (id) => {
    return request({
        url: '/user/' + id,
        method: 'delete'
    })
}

// 批量删除用户
export const deleteUsers = (ids) => {
    return request({
        url: '/user',
        method: 'delete',
        data: ids
    })
}

// 获取教师列表
export const getTeacherList = (page, size, params) => {
    return request({
        url: '/teacher?page=' + page + '&size=' + size,
        method: 'get',
        params
    })
}

//获取所有教师
export const getAllTeacher = () => {
    return request({
        url: '/teacher/all',
        method: 'get'
    })
}

// 添加教师
export const addTeacher = (data) => {
    return request({
        url: '/teacher',
        method: 'post',
        data
    })
}

// 修改教师信息
export const updateTeacher = (id, data) => {
    return request({
        url: '/teacher/' + id,
        method: 'put',
        data
    })
}

// 删除教师
export const deleteTeacher = (id) => {
    return request({
        url: '/teacher/' + id,
        method: 'delete'
    })
}

// 批量删除教师
export const deleteTeachers = (ids) => {
    return request({
        url: '/teacher',
        method: 'delete',
        data: ids
    })
}

// 获取学生列表
export const getStudentList = (page, size, params) => {
    return request({
        url: '/student?page=' + page + '&size=' + size,
        method: 'get',
        params
    })
}

// 获取所有学生
export const getAllStudent = () => {
    return request({
        url: '/student/all',
        method: 'get'
    })
}

// 添加学生
export const addStudent = (data) => {
    return request({
        url: '/student',
        method: 'post',
        data
    })
}

// 修改学生信息
export const updateStudent = (id, data) => {
    return request({
        url: '/student/' + id,
        method: 'put',
        data
    })
}

// 删除学生
export const deleteStudent = (id) => {
    return request({
        url: '/student/' + id,
        method: 'delete'
    })
}

// 批量删除学生
export const deleteStudents = (ids) => {
    return request({
        url: '/student',
        method: 'delete',
        data: ids
    })
}

// 获取班级列表
export const getClazzList = (page, size, params) => {
    return request({
        url: '/class?page=' + page + '&size=' + size,
        method: 'get',
        params
    })
}

// 获取所有班级
export const getAllClass = () => {
    return request({
        url: '/class/all',
        method: 'get'
    })
}

// 添加班级
export const addClazz = (data) => {
    return request({
        url: '/class',
        method: 'post',
        data
    })
}

// 修改班级信息
export const updateClazz = (id, data) => {
    return request({
        url: '/class/' + id,
        method: 'put',
        data
    })
}

// 删除班级
export const deleteClazz = (id) => {
    return request({
        url: '/class/' + id,
        method: 'delete'
    })
}

// 批量删除班级
export const deleteClazzs = (ids) => {
    return request({
        url: '/class',
        method: 'delete',
        data: ids
    })
}

// 获取课程列表
export const getCourseList = (page, size, params) => {
    return request({
        url: '/course?page=' + page + '&size=' + size,
        method: 'get',
        params
    })
}

// 获取所有课程
export const getAllCourse = () => {
    return request({
        url: '/course/all',
        method: 'get'
    })
}

// 添加课程
export const addCourse = (data) => {
    return request({
        url: '/course',
        method: 'post',
        data
    })
}

// 修改课程信息
export const updateCourse = (id, data) => {
    return request({
        url: '/course/' + id,
        method: 'put',
        data
    })
}

// 删除课程
export const deleteCourse = (id) => {
    return request({
        url: '/course/' + id,
        method: 'delete'
    })
}

// 批量删除课程
export const deleteCourses = (ids) => {
    return request({
        url: '/course',
        method: 'delete',
        data: ids
    })
}

// 获取成绩列表
export const getScoreList = (page, size, params) => {
    return request({
        url: '/grade?page=' + page + '&size=' + size,
        method: 'get',
        params
    })
}

// 添加成绩
export const addScore = (data) => {
    return request({
        url: '/grade',
        method: 'post',
        data
    })
}

// 修改成绩信息
export const updateScore = (id, data) => {
    return request({
        url: '/grade/' + id,
        method: 'put',
        data
    })
}

// 删除成绩
export const deleteScore = (id) => {
    return request({
        url: '/grade/' + id,
        method: 'delete'
    })
}

// 批量删除成绩
export const deleteScores = (ids) => {
    return request({
        url: '/grade',
        method: 'delete',
        data: ids
    })
}

// 获取选课列表
export const getSelectionList = (page, size, params) => {
    return request({
        url: '/enrollment?page=' + page + '&size=' + size,
        method: 'get',
        params
    })
}

// 添加选课
export const addSelection = (data) => {
    return request({
        url: '/enrollment',
        method: 'post',
        data
    })
}

// 修改选课信息
export const updateSelection = (id, data) => {
    return request({
        url: '/enrollment/' + id,
        method: 'put',
        data
    })
}

// 删除选课
export const deleteSelection = (id) => {
    return request({
        url: '/enrollment/' + id,
        method: 'delete'
    })
}

// 批量删除选课
export const deleteSelections = (ids) => {
    return request({
        url: '/enrollment',
        method: 'delete',
        data: ids
    })
}

//获取各个班级学生的人数
export const getStudentCountByClass = () => {
    return request({
        url: '/data/student',
        method: 'get'
    })
}

//获取各个教师教授的课程数
export const getCourseCountByTeacher = () => {
    return request({
        url: '/data/teacher',
        method: 'get'
    })
}

//获取课程的选课人数
export const getSelectionCountByCourse = () => {
    return request({
        url: '/data/enrollment',
        method: 'get'
    })
}

// 获取班级课表
export const getClassSchedule = (id, page, size) => {
    return request({
        url: '/timetable/class/' + id + '?page=' + page + '&size=' + size,
        method: 'get'
    })
}

// 添加班级课表
export const addClassSchedule = (data) => {
    return request({
        url: '/timetable',
        method: 'post',
        data
    })
}
//修改班级课表
export const updateClassSchedule = (id, data) => {
    return request({
        url: '/timetable/' + id,
        method: 'put',
        data
    })
}

// 删除班级课表
export const deleteClassSchedule = (id) => {
    return request({
        url: '/timetable/' + id,
        method: 'delete'
    })
}



export default service